﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ClusterMethodType.cs" company="DissingNelleman">
//   
// All rights reserved. </copyright>
// <summary>
//   The cluster method type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace ServiceLibrary.Services.Dto
{
    using System;
    using System.Runtime.Serialization;

    /// <summary>
    /// The cluster method type.
    /// </summary>
    [DataContract]
    public class ClusterMethodType
    {
        #region Public Properties

        /// <summary>
        /// Gets or sets the id.
        /// </summary>
        [DataMember]
        public Guid ID { get; set; }

        /// <summary>
        /// Gets or sets the name.
        /// </summary>
        [DataMember]
        public string Name { get; set; }

        #endregion

        #region Public Methods and Operators

        /// <summary>
        /// The convert.
        /// </summary>
        /// <param name="type">
        /// The type.
        /// </param>
        /// <returns>
        /// The <see cref="ClusterMethodType"/>.
        /// </returns>
        public static ClusterMethodType Convert(Models.Domain.ClusterMethodType type)
        {
            if (type != null)
            {
                var dto = new ClusterMethodType { ID = type.ID, Name = type.Name };
                return dto;
            }
            
            return null;
        }

        #endregion
    }
}

namespace ServiceLibrary.Services.Queries
{
    using System.Runtime.Serialization;

    using NHibernate;

    using ServiceLibrary.Actioners.Activities;
    using ServiceLibrary.Services.Results;

    /// <summary>
    /// The cluster method type query.
    /// </summary>
    [DataContract]
    public class ClusterMethodTypeQuery : IQuery
    {
        #region Public Methods and Operators

        /// <summary>
        /// The execute.
        /// </summary>
        /// <param name="hsession">
        /// The hsession.
        /// </param>
        /// <returns>
        /// The <see cref="IResult"/>.
        /// </returns>
        public override IResult Execute(ISession hsession)
        {
            var actioner = new ClusterMethodActioner(hsession, null);

            return actioner.QueryAllClusterMethodTypes(this);
        }

        #endregion
    }
}

namespace ServiceLibrary.Services.Results
{
    using System.Collections.Generic;
    using System.Runtime.Serialization;

    using ServiceLibrary.Services.Dto;

    /// <summary>
    /// The cluster method type result.
    /// </summary>
    [DataContract]
    public class ClusterMethodTypeResult : IResult
    {
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="ClusterMethodTypeResult"/> class.
        /// </summary>
        public ClusterMethodTypeResult()
        {
            this.List = new List<ClusterMethodType>();
        }

        #endregion

        #region Public Properties

        /// <summary>
        /// Gets or sets the list.
        /// </summary>
        [DataMember]
        public List<ClusterMethodType> List { get; set; }

        /// <summary>
        /// Gets or sets the total row count.
        /// </summary>
        [DataMember]
        public int TotalRowCount { get; set; }

        #endregion
    }
}